package vn.edu.nuce.bean;

import java.util.List;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.ViewScoped;

import org.primefaces.context.RequestContext;

import vn.edu.nuce.model.PhongMay;
import vn.edu.nuce.service.PhongMayService;

@ManagedBean(name="phongMayBean")
@ViewScoped
public class PhongMayBean {
	@ManagedProperty(value="#{PhongMayService}")
	PhongMayService phongMayService;
	
	List<PhongMay> phongMayList;
	private PhongMay phongMaySelected = new PhongMay();

	public String convertStatus(boolean status){
		if (status){
			return "Đang hoạt động";
		} else return "Đang ngừng hoạt động";
	}
	
	public void chonPhongMay(String id){
		phongMaySelected = getPhongMayService().getById(id);
	}
	
	public void editPhong(){
		getPhongMayService().update(phongMaySelected);
		RequestContext.getCurrentInstance().execute("dlg.hide()");
	}

	public List<PhongMay> getPhongMayList() {
		phongMayList = getPhongMayService().getPhongMayList();
		return phongMayList;
	}

	public void setPhongMayList(List<PhongMay> phongMayList) {
		this.phongMayList = phongMayList;
	}

	public PhongMayService getPhongMayService() {
		return phongMayService;
	}

	public void setPhongMayService(PhongMayService phongMayService) {
		this.phongMayService = phongMayService;
	}
	public PhongMay getPhongMaySelected() {
		return phongMaySelected;
	}

	public void setPhongMaySelected(PhongMay phongMaySelected) {
		this.phongMaySelected = phongMaySelected;
	}

	
}
